<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../../三段/jquery.js"></script>
  </head>
  <body>
    <button>请求1</button>
  </body>
  <script>
    async function fun() {
      await $.ajax({
        url: 'http://localhost:3000/api/getUser',
        type: 'get',
        dataType: 'json',
        success: function (res) {
          console.log(res)
        },
      })
      return 'helloAsync'
    }
    console.log(fun())
    var n, m
    $(function () {
      $('button').click(function () {
        new Promise((resolve, reject) => {
          setTimeout(() => {
            n = 1
            console.log('定时器1执行玩了')
            resolve(n)
          }, 1000)
        })
          .then((res) => {
            console.log('请求2开始')
            return new Promise((resolve, reject) => {
              $.ajax({
                url: 'https://liu.zzgoodqc.cn/gaode?n=' + res,
                dataType: 'json',
                success: function (data) {
                  console.log('请求2完成')
                  m = 666
                  resolve(m)
                },
              })
            })
          })
          .then(function (res) {
            console.log(res, '请求3开始')
            $.ajax({
              url: 'https://liu.zzgoodqc.cn/gaode?res=' + res,
              dataType: 'json',
              success: function (data) {
                console.log('请求3完成')
              },
            })
          })

        // if (n != undefined) {
        //   $.ajax({
        //     url: 'https://liu.zzgoodqc.cn/gaode',
        //     dataType: 'json',
        //     success: function (data) {
        //       console.log('请求1')
        //       m = 666
        //     },
        //   })
        // }
        // if (m != undefined) {
        //   $.ajax({
        //     url: 'https://liu.zzgoodqc.cn/gaode',
        //     dataType: 'json',
        //     success: function (data) {
        //       console.log('请求2')
        //     },
        //   })
        // }
      })
    })
  </script>
</html>
